import axios from './axios'
let api = 'https://ethrct.itobox.io' // 登陆
// let api = 'http://eth.itojj.com' // 测试
let user = 'http://api.itobox.io' // jump
// let user = 'http://jump.51ito.io' // 测试

// 注册
export function register (params) {
  return axios.post(api + '/api/v1/register', params)
              .then(res => res.data)
}

// 注册验证码
export function registerEmail (params) {
  return axios.post(api + '/api/v1/register.email', params)
              .then(res => res.data)
}

// 获取用户信息
export function getUser (params) {
  return axios.get(api + '/api/v1/user', {params})
              .then(res => res.data)
}

// 登录
export function login (params) {
  return axios.post(api + '/api/v1/login', params)
              .then(res => res.data)
}

// 找回密码验证码
export function passwordEmail (params) {
  return axios.post(api + '/api/v1/password.email', params)
              .then(res => res.data)
}

// 修改密码
export function passwordReset (params) {
  return axios.post(api + '/api/v1/reset.password', params)
              .then(res => res.data)
}

// 充值地址列表
export function collectionAccount (params) {
  return axios.post(api + '/api/v1/collection.account', params)
              .then(res => res.data)
}

// 充值
export function recharge (params) {
  return axios.post(api + '/api/v1/recharge', params)
              .then(res => res.data)
}

// 获取提现验证码
export function withdrawEmail (params) {
  return axios.get(api + '/api/v1/withdraw.email', {params})
              .then(res => res.data)
}

// 提现
export function withdraw (params) {
  return axios.post(api + '/api/v1/withdraw', params)
              .then(res => res.data)
}

// 创建回合
export function create (params) {
  return axios.get(user + '/api/a/create', { params })
              .then(res => res.data)
}

// 参与回合
export function join (params) {
  return axios.get(user + '/api/p/join', { params })
              .then(res => res.data)
}

// 获取回合信息
export function info (params) {
  return axios.get(user + '/api/a/info', { params })
              .then(res => res.data)
}

// 点击分享链接或者游戏⼊⼝检查回合状态信息接⼝
export function check (params) {
  console.log(params)
  return axios.get(user + '/api/a/check', { params })
              .then(res => res.data)
}

// ⽤户成绩上报
export function report (params) {
  return axios.get(user + '/api/p/report', { params })
              .then(res => res.data)
}

// ⽤户游戏记录
export function record (params) {
  return axios.get(user + '/api/u/record', { params })
              .then(res => res.data)
}

// ⽤户游戏开始
export function start (params) {
  return axios.get(user + '/api/p/start', { params })
              .then(res => res.data)
}

// 游戏
export function getrooms (params) {
  return axios.get(api + '/api/v1/game/record_list', { params })
              .then(res => res.data)
}